package com.jason.kotlin.gank.api

import com.jason.kotlin.gank.model.GankApiResponse
import com.jason.kotlin.gank.model.GankBannerBean
import com.jason.kotlin.gank.model.GankCategoryBean
import com.jason.kotlin.gank.model.GankDataBean
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Path


interface GankService {

    companion object {
        /**
         * 浏览数
         */
        val HOT_TYPE_VIEWS = "views"

        /**
         * 点赞数
         */
        val HOT_TYPE_LIKES = "likes"

        /**
         * 评论数
         */
        val HOT_TYPE_COMMENTS = "comments"

        /**
         * Article
         */
        val CATEGORY_ARTICLE = "Article"

        /**
         * GanHuo
         */
        val CATEGORY_GANHUO = "GanHuo"

        /**
         * Girl
         */
        val CATEGORY_GIRL = "Girl"

        /**
         * 全部类型
         */
        val TYPE_ALL = "All"

        /**
         * 全部类型
         */
        val TYPE_ANDROID = "Android"

        /**
         * 全部类型
         */
        val TYPE_IOS = "iOS"

        /**
         * 全部类型
         */
        val TYPE_FLUTTER = "Flutter"

        /**
         * 全部类型
         */
        val TYPE_GIRL = "Girl"

    }

    /**
     * 首页banner轮播的数据
     */
    @GET("/api/v2/banners")
    suspend fun loadBanners(): GankApiResponse<List<GankBannerBean>>

    /**
     * 首页-本周最热干货前二十条数据
     * https://gank.io/api/v2/hot/views/category/GanHuo/count/20
     */
    @GET("/api/v2/hot/{hot_type}/category/{category}/count/{count}")
    suspend fun loadWeekHotData(
        @Path("hot_type") type: String,
        @Path("category") category: String,
        @Path("count") count: Int
    ): GankApiResponse<List<GankDataBean>>

    /**
     * 分类数据 API
     * https://gank.io/api/v2/data/category/<category>/type/<type>/page/<page>/count/<count>
     *     https://gank.io/api/v2/data/category/Girl/type/Girl/page/1/count/10
     */
    @GET("/api/v2/data/category/{category}/type/{type}/page/{page}/count/{count}")
    suspend fun loadCategoryData(
        @Path("category") category: String,
        @Path("type") type: String,
        @Path("page") page: Int,
        @Path("count") count: Int
    ): GankApiResponse<List<GankDataBean>>

    /**
     * 随机数据 API
     * https://gank.io/api/v2/random/category/<category>/type/<type>/count/<count>
     */
    @GET("/api/v2/random/category/{category}/type/{type}/count/{count}")
    suspend fun getRandomData(
        @Path("category") category: String?,
        @Path("type") type: String?,
        @Path("count") count: Int
    ): GankApiResponse<List<GankDataBean>>

    /**
     * 获取所有分类的具体子分类
     * https://gank.io/api/v2/categories/<category_type>
     */
    @GET("/api/v2/categories/{category_type}")
    suspend fun getCategories(@Path("category_type") categoryType: String): GankApiResponse<List<GankCategoryBean>>

    /**
     * 搜索
     * https://gank.io/api/v2/search/android/category/All/type/All/page/1/count/10
     */
    @Headers("Cache-Control: public, max-age=120")
    @GET("/api/v2/search/{keyword}/category/All/type/All/page/{page}/count/{count}")
    suspend fun getSearchData(
        @Path("keyword") keyword: String?,
        @Path("page") page: Int,
        @Path("count") count: Int
    ): GankApiResponse<List<GankDataBean>>

    /**
     * 文章详情 API
     * https://gank.io/api/v2/post/<post_id>
     */
    @GET("/api/v2/post/{post_id}")
    suspend fun getArticleDetail(
        @Path("post_id") postId: String
    ): GankApiResponse<List<GankDataBean>>

}

